function throttle(callback, time) {
  let ptr;
  return function(...args) {
    if(ptr) {
      return;
    }
    ptr = setTimeout(function() {
      callback.apply(null, args);
      ptr = null;
    }, time)
  }
}

function throttle2(callback, time) {
  let cur = +new Date();
  let task = [];
  return function(...args) {
    task.push(callback);
    let cur2 = +new Date();
    if(cur2 - cur < time) {
      return;
    }
    let fn = task.pop();
    task = [];
    return fn(...args);
  }
}

let fun = throttle(function() {
  console.log('throttle')
}, 1000);

setInterval(fun, 100);